#ifndef __IntroState_h__
#define __IntroState_h__

#include <Ogre.h>
#include <OIS/OIS.h>

#include <GameState.h>
#include "RecordManager.h"

#define RECORDFILE ".recordsTetris"

#define _LIGHT_MASK_STAGE_	1 << 0
#define _LIGHT_MASK_MENU_		1 << 1

#define _QUERY_MASK_STAGE_	1 << 0
#define _QUERY_MASK_MENU_		1 << 1

enum MenuState {MENU, RECORDS, CREDITS};

class IntroState: public Ogre::Singleton<IntroState>, public GameState
{
  public:
    IntroState() {}

    void enter();
    void exit();
    void pause();
    void resume();

    void keyPressed(const OIS::KeyEvent&);
    void keyReleased(const OIS::KeyEvent&);

    void mouseMoved(const OIS::MouseEvent&);
    void mousePressed(const OIS::MouseEvent&, OIS::MouseButtonID);
    void mouseReleased(const OIS::MouseEvent&, OIS::MouseButtonID);

    bool frameStarted(const Ogre::FrameEvent&);
    bool frameEnded(const Ogre::FrameEvent&);

    // Heredados de Ogre::Singleton.
    static IntroState& getSingleton();
    static IntroState* getSingletonPtr();

  protected:
    Ogre::Root* _root;
    Ogre::SceneManager* _sceneMgr;
    Ogre::OverlayManager* _overlayMgr;
    Ogre::Viewport* _viewport;
    Ogre::Camera* _camera;
    Ogre::RaySceneQuery* _raySceneQuery;
    TrackManager* _pTrackManager;
    SoundFXManager* _pSoundFXManager;
    RecordManager* _pRecordMgr;
    bool _exitGame;
    int _menuState;

    Ogre::Ray setRayQuery(int posx, int posy, Ogre::uint32 mask);
    Ogre::SceneNode* buildCamera();
    void setSceneShadow();
    Ogre::Light* buildStageLight();
    Ogre::SceneNode* buildStage();
    Ogre::Light* buildMenuLight();
    Ogre::SceneNode* buildMenu();
    Ogre::SceneNode* buildOptions();
    Ogre::SceneNode* buildRecords();
    Ogre::SceneNode* buildCredits();
};

#endif
